package com.coocaa.ops.plus.dashboard.third.internalapi;

import com.coocaa.ops.common.core.base.model.R;
import feign.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.net.URI;

/**
 * @author bjh
 * @description
 * @date 2021/2/3 14:44
 */
@FeignClient(name = "internal-api-service")
public interface InternalApiFeignClient {
    /**
     * 获取缓存key类型
     *
     * @return
     */
    @RequestMapping("/tvos/internal//listKeyType")
    R listKeyType(URI uri);

    /**
     * 获取缓存key列表
     *
     * @return
     * @RequestParam key
     * @RequestParam page
     * @RequestParam pageSize
     * @RequestParam match
     */
    @RequestMapping(value = "/tvos/internal/listKey")
    R listKey(URI uri, @RequestParam("key") String key,
              @RequestParam("cacheEnv") String cacheEnv,
              @RequestParam("page") Integer page,
              @RequestParam(value = "pageSize") Integer pageSize,
              @RequestParam(value = "match") Integer match);

    /**
     * 获取指定key的值
     *
     * @return
     * @RequestParam key
     */
    @RequestMapping("/tvos/internal/getValByKey")
    R getValByKey(URI uri, @RequestParam("key") String key, @RequestParam("cacheEnv") String cacheEnv
    );

    /**
     * 删除指定key
     *
     * @return
     * @RequestParam keys
     * @RequestParam match
     */
    @RequestMapping("/tvos/internal/delByKey")
    R delByKey(URI uri, @RequestParam("keys") String[] keys,
               @RequestParam("cacheEnv") String cacheEnv,
               @RequestParam("sign") String sign,
               @RequestParam("match") Integer match);

    /**
     * 存活时间
     *
     * @return
     * @RequestParam key
     */
    @RequestMapping("/tvos/internal/ttl")
    R ttl(URI uri, @RequestParam("key") String key, @RequestParam("cacheEnv") String cacheEnv);


    /**
     * 开关信息
     *
     * @param type
     * @return
     */
    @RequestMapping(value = "/tvos/internal/switcher/getSwitcherInfo", method = RequestMethod.GET)
    R getSwitcherInfo(URI uri, @Param("type") String type);

    /**
     * 获取所有的开关信息
     *
     * @return
     */
    @RequestMapping(value = "/tvos/internal/switcher/getAllSwitcher", method = RequestMethod.GET)
    R getAllSwitcher(URI uri);
}
